package com.soft.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.soft.entity.Dept;
import com.soft.service.DeptService;

@RestController
@RequestMapping("/dept")
public class DeptController {
	@Autowired
	private DeptService deptService;
	@RequestMapping("/queryAllDept")
	public List<Dept> queryAll(){
		return deptService.queryAll();
	}
	@RequestMapping("/queryByLoc")
	public List<Dept> queryByLoc(String deptLoc){
		return deptService.queryByLoc(deptLoc);
	}
	@RequestMapping("/insertOne")
	public String insertOne(String deptName,String loc) {
		int num = deptService.insertOne(deptName, loc);
		if(num==1) {
			return deptName+"加入成功";
		}else {
			return deptName+"加入失败";
		}
	}
	@RequestMapping("/deleteById")
	public String deleteById(String deptno) {
		int num = deptService.deleteById(deptno);
		if(num==1){
			return "删除成功";
		}else {
			return "删除失败";
		}
	}
}
